package search;

public class BinarySearch {
	private static int[] orderArray = new int[]{1,6,12,29,34,55,87,96,124,156};

	public static int search(int key){
		int mid=0;
		int low=0;
		int high=orderArray.length-1;
		while(low<=high){
			mid=(low+high)/2;
			if(key<orderArray[mid]){
				high=mid-1;
			}else if(key>orderArray[mid]){
				low=mid+1;
			}else{
				return mid;
			}
		}
		return -1;
	}
	
	public static void main(String[] args) throws Exception{
		System.out.println("position:"+search(12));
		System.out.println("position:"+search(380));
	}
}
